Failed Conditions
Push — master ( f5e7b3...711045 )
by Yo
01:30
created

index.js ➔ ???   A

Complexity

Conditions 4
Paths 8

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 5
Bugs 0 Features 0
Metric Value
cc 4
c 5
b 0
f 0
nc 8
nop 1
dl 0
loc 10
rs 9.2
1
"use strict";
2
3
const winston = require('winston');
4
const config = require('config');
5
const path = require('path');
6
const moment = require('moment');
7
const Logger = require('./Logger');
8
9
const loggerConfig = config.logger;
10
11
const format = (options) => {
12
    return ' [' + options.level.toUpperCase() + ']'
13
        + '[' + moment(new Date()).format('YYYY-MM-DD HH:mm:ss') + ']'
14
        + (options.message ? ' ' + options.message : '')
15
        + (
16
            options.meta && Object.keys(options.meta).length
17
                ? ' ' + JSON.stringify(options.meta)
18
                : ''
19
        );
20
};
21
22
/**
23
 * @type {Logger} Default logger for the app. Use console output and a log file
24
 */
25
module.exports = new Logger(new winston.Logger({
26
    transports: [
27
        new winston.transports.Console({
28
            level: config.debug === true ? 'debug' : loggerConfig.level,
29
            name: 'console',
30
            json: false,
31
            colorize: true
32
        }),
33
        new  winston.transports.File({
34
            name: 'default',
35
            level: config.debug === true ? 'debug' : loggerConfig.level,
36
            filename: path.resolve(loggerConfig.path, './server.log'),
37
            maxsize: 1024,
38
            maxFiles: 4,
39
            json: false,
40
            formatter: format
41
        })
42
    ]
43
}));
44